{include file="public/header" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <fieldset id="searchFieldset_currentTableRenderId" class="table-search-fieldset">
                        <legend>条件搜索</legend>
                        <form class="layui-form layui-form-pane form-search">
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">订单项目类型</label>
                                <div class="layui-input-inline">
                                    <select name="xmtype">
                                        <option value="">类型</option>
                                        {foreach $types as $k => $v}
                                        {if $k != 1}
                                        <option value="{$k}" {if !empty(input('get.xmtype')) &&
                                            input('get.xmtype')==$k}selected{/if}>{$v|default=''}</option>
                                        {/if}
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">订单派单类型</label>
                                <div class="layui-input-inline">
                                    <select name="ordertype">
                                        <option value="">派单类型</option>
                                        {foreach $ordertype as $k => $v}
                                        <option value="{$k}" {if !empty(input('get.ordertype')) &&
                                            input('get.ordertype')==$k}selected{/if}>{$v|default=''}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">报销督导</label>
                                <div class="layui-input-inline">
                                    <select name="uuuid" lay-search="">
                                        <option value="">报销督导</option>
                                        {foreach $uuulist as $k => $v}
                                        <option value="{$v.id}" {if !empty(input('get.uuuid')) &&
                                            input('get.uuuid')==$v.id}selected{/if}>{$v.account}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">是否打款(仅筛选通过报销)</label>
                                <div class="layui-input-inline">
                                    <select name="dk">
                                        <option value="">类型</option>
                                        <option value="1" {if !empty(input('get.dk')) &&
                                            input('get.dk')==1}selected{/if}>未打款</option>
                                        <option value="2" {if !empty(input('get.dk')) &&
                                            input('get.dk')==2}selected{/if}>已打款</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">报销日期</label>
                                <div class="layui-input-inline">
                                    <input type="text" lay-verify="timestypeverify" name="timess" placeholder="时间段"
                                        value="{:input('get.timess')}" autocomplete="off" class="layui-input timess">
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">出发日期</label>
                                <div class="layui-input-inline">
                                    <input type="text" lay-verify="timestypeverify" name="timess2" placeholder="时间段"
                                        value="{:input('get.timess2')}" autocomplete="off" class="layui-input timess">
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">报销单类型</label>
                                <div class="layui-input-inline">
                                    <select name="type">
                                        <option value="">类型</option>
                                        <option value="1" {if !empty(input('get.type')) &&
                                            input('get.type')==1}selected{/if}>选址</option>
                                        <option value="2" {if !empty(input('get.type')) &&
                                            input('get.type')==2}selected{/if}>开业</option>
                                        <option value="99" {if !empty(input('get.type')) &&
                                            input('get.type')==99}selected{/if}>日常报销</option>
                                        <option value="100" {if !empty(input('get.type')) &&
                                            input('get.type')==100}selected{/if}>预支费用</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">报销单状态</label>
                                <div class="layui-input-inline">
                                    <select name="status">
                                        <option value="">状态</option>
                                        {foreach $reimburs_status as $k => $y}
                                        <option value="{$k}" {if !empty(input('get.status')) &&
                                            input('get.status')==$k}selected{/if}>{$y}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">关键字</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="title" placeholder="商铺名称|备注|联系人|联系电话|地址"
                                        value="{:input('get.title')}" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="sreach">搜索</button>
                            </div>
                        </form>
                    </fieldset>
                </div>
                <div class="layui-card-header">
                    共有数据：<strong id="count">{$list->total()}</strong> 条
                </div>
                <div class="layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                            <tr>
                                <th>
                                    <div class="layui-table-cell">ID</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">关联派单</div>
                                </th>
                                <th>
                                    <div style="max-width: 50px;" class="layui-table-cell">派单目前状态</div>
                                </th>
                                <th style="width: 50px;">
                                    <div class="layui-table-cell">回款说明(选址报销)</div>
                                </th>
                                <th>
                                    <div>报销信息</div>
                                </th>
                                <!-- <th>
                                    <div class="layui-table-cell">基本信息</div>
                                </th> -->
                                <th style="width: 100px;">
                                    <div class="layui-table-cell">报销状态</div>
                                </th>
                                <th style="width: 50px;">
                                    <div class="layui-table-cell">组别</div>
                                </th>
                                <th style="width: 60px;">
                                    <div class="layui-table-cell">客户姓名</div>
                                </th>
                                <th style="width: 100px;">
                                    <div class="layui-table-cell">报销明细</div>
                                </th>
                                <th style="width: 100px;">
                                    <div class="layui-table-cell">审核说明</div>
                                </th>
                                {if $admintype != 3}
                                <th>
                                    <div class="layui-table-cell">操作</div>
                                </th>
                                {/if}
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $list as $v}
                            <tr>
                                <td>
                                    <div class="layui-table-cell">{$v.id|default=''}</div>
                                </td>
                                <td>
                                    {if $v.orderid > 0}
                                    <a title="查看任务单" onclick="open_add('编辑','/shop/shoplist?id={$v.orderid}')"
                                        href="javascript:;" class="layui-btn layui-btn-sm">
                                        查看任务单
                                    </a>
                                    {elseif $v.type == 100}
                                    <a title="费用预支" href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger">
                                        费用预支
                                    </a>
                                    {else}
                                    <a title="日常报销" href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger">
                                        日常报销
                                    </a>
                                    {/if}
                                </td>
                                <td>
                                    <div>{$v.schedule_text|default='无'}</div>
                                </td>
                                <td style="padding:0 15px">
                                    {if !empty($v.hktype)}
                                    回款情况:{$v.hktype_text|default='无'}<br />
                                    {if $v.hktype >= 3}
                                    回款说明:{$v.hktext|default='无'}
                                    {/if}
                                    {else}
                                    无
                                    {/if}

                                </td>
                                <td>
                                    <div style="color: red;padding:0 15px">报销人:{$v.user_name|default='系统'}
                                    </div>
                                    {if $v.orderid > 0}
                                    <div style="padding:0 15px">
                                        {if !empty($v.jobtypename)}
                                        派单类型:{$v.jobtypename|default=''}
                                        {else}
                                        派单类型:{$v.typename|default=''}
                                        {/if}
                                    </div>
                                    {elseif $v.type == 100}
                                    <div style="padding:0 15px">报销类型:预支费用</div>
                                    {else}
                                    <div style="padding:0 15px">报销类型:日常报销</div>
                                    {/if}
                                    <!-- <div class="layui-table-cell">报销类型:{$v.typename|default=''}</div> -->
                                    <div style="padding:0 15px">
                                        报销总额:{$v.total|default=''}</div>
                                </td>
                                <!-- <td>
                                    <div class="layui-table-cell">客户:{$v.name|default='系统'}</div>
                                    <div style="padding:0 15px" id="layer-photos-demo" class="layer-photos-demo">
                                        报销类型:{$v.address|default=''}
                                    </div>
                                    <div class="layui-table-cell">报销类型:{$v.address|default=''}</div>
                                    <div class="layui-table-cell">报销总额:{$v.total|default=''}</div>
                                </td> -->
                                <td>
                                    <div class="layui-table-cell">{$v.status_text}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{if
                                        !empty($v.groupname)}{$v.groupname|default=''}{/if}</div>
                                </td>
                                <td>
                                    {if $v.orderid > 0}
                                    <div class="layui-table-cell">{if !empty($v.name)}{$v.name|default=''}{/if}</div>
                                    <div class="layui-table-cell">{if !empty($v.phone)}{$v.phone|default=''}{/if}</div>
                                    {else}
                                    <div class="layui-table-cell">无</div>
                                    {/if}
                                </td>
                                <td style="width:150px">
                                    {foreach $v.log as $k => $m}
                                    <div style="background-color: #ecf5ff;margin-bottom:10px;border-radius: 5px;">
                                        <!-- <div style="font-size: 18px;font-weight: bold;" class="layui-table-cell">
                                            明细记录{$k+1}</div> -->
                                        <!-- <div class="layui-table-cell">金额:{$m.money}</div> -->
                                        <div style="padding:0 10px">
                                            发生消费日期:{$m.dates|default=''}
                                        </div>
                                        <div style="padding:0 10px">
                                            {if
                                            !empty($v.address)}地址:{$v.address|default=''}{/if}</div>
                                        <div style="padding:0 10px;max-width: 200px; word-wrap: break-word;">
                                            说明:{$m.remark}
                                        </div>
                                        <input id="looktext{$m.id}" type="hidden" value="{$m.remark}" />
                                        <div style="padding:0 10px">
                                            <a title="查看格式化说明" onclick="chakans('{$m.id}')" href="javascript:;"
                                                class="layui-btn layui-btn-sm">
                                                查看格式化说明
                                            </a>
                                        </div>
                                        <div style="padding:0 10px">凭证:
                                        </div>
                                        <div style="padding:0 10px" id="layer-photos-demo" class="layer-photos-demo">
                                            <div style="padding:10px;border-radius: 5px;">
                                                {foreach $m.pinzheng as $ms}
                                                <img height="50" layer-pid="" layer-src="{$ms.url}" src="{$ms.url}" />
                                                {/foreach}
                                            </div>
                                        </div>
                                        {if !empty($m.fujian) && count($m.fujian) > 0}
                                        <div style="padding:0 10px">附件:
                                        </div>
                                        <div style="padding:0 10px" id="layer-photos-demo" class="layer-photos-demo">
                                            <div style="padding:10px;border-radius: 5px;">
                                                {foreach $m.fujian as $ms}
                                                <img height="50" layer-pid="" layer-src="{$ms.url}" src="{$ms.url}" />
                                                {/foreach}
                                            </div>
                                        </div>
                                        {/if}
                                    </div>
                                    {/foreach}
                                </td>
                                <td style="padding:0 10px">{$v.text|default='无'}<br />
                                    <div {if $adminid !=$v.adminid}style="color:red" {/if}>
                                        {$v.peoples}</div>
                                    {$v.created|default='无'}
                                </td>
                                {if $admintype != 3}
                                <td class="td-manage">
                                    <div class="layui-table-cell">
                                        {if $admintype == 1 || $admintype == 2}
                                        {if $v.htshenghe == 1}<a title="合同邮寄查看"
                                            onclick="open_add2('合同邮寄查看','/shop/uploadtk?user_id={$v.user_id}')"
                                            href="javascript:;" class="layui-btn layui-btn-sm">
                                            合同邮寄查看
                                        </a>{elseif $v.htshenghe == 2}[已邮寄]{elseif $v.htshenghe ==
                                        3}[审核驳回]{else}{/if}
                                        {if empty($v.htshenghe) || $v.htshenghe == 3}
                                        <a title="发送合同邮寄提醒"
                                            onclick="open_status(this, '/shop/hetong_message', '{$v.id}', '{$v.user_id}')"
                                            href="javascript:;" class="layui-btn layui-btn-sm layui-bg-blue">
                                            发送寄合同通知:{$v.cishu}次
                                        </a>
                                        {/if}
                                        {/if}
                                        {if $v.status == 1 && ($admintype == 1 || $admintype == 4)}
                                        {if $v.baoxiaosons == 2 && $admintype != 4}
                                        报销审批员审核
                                        {else}
                                        {if $v.orderid > 0}
                                        <a title="同意并联系打款"
                                            onclick="promt_alertss('填写报销说明，如无需说明请填写无', '/shop/reimburs_status', '{$v.id}', 2)"
                                            href="javascript:;" class="layui-btn layui-btn-sm">
                                            同意并联系打款
                                        </a>
                                        {else}
                                        <a title="同意并联系打款"
                                            onclick="open_alerterr('填写报销说明，如无需说明请填写无', '/shop/reimburs_status', '{$v.id}', 2,'{$v.groups}')"
                                            href="javascript:;" class="layui-btn layui-btn-sm">
                                            同意并联系打款
                                        </a>
                                        {/if}
                                        <a title="驳回"
                                            onclick="promt_alertss('填写驳回理由', '/shop/reimburs_status','{$v.id}',3)"
                                            href="javascript:;" class="layui-btn layui-btn-sm">
                                            驳回
                                        </a>
                                        {/if}
                                        {else}
                                        {if $v.status == 2 && $v.dk == 1 && ($admintype == 2 || $admintype == 4)}
                                        {if $v.baoxiaosons == 2 && $admintype != 4}
                                        报销审批员审核
                                        {else}
                                        <a title="我已打款"
                                            onclick="open_status(this, '/shop/reimburs_status', '{$v.id}', 9)"
                                            href="javascript:;" class="layui-btn layui-btn-sm layui-bg-blue">
                                            已打款确认
                                        </a>
                                        {/if}
                                        {else}
                                        <a title="{$v.status_text}" href="javascript:;"
                                            class="layui-btn layui-btn-sm layui-bg-cyan">
                                            {$v.status_text}
                                        </a>
                                        {/if}
                                        {if $v.status == 2}
                                        {if $v.baoxiaosons == 2 && $admintype != 4}
                                        报销审批员审核
                                        {else}
                                        <a title="撤回重审"
                                            onclick="open_status(this, '/shop/reimburs_status', '{$v.id}', 8)"
                                            href="javascript:;" class="layui-btn layui-btn-sm layui-bg-red">
                                            撤回重审
                                        </a>
                                        {/if}
                                        {/if}
                                        {/if}
                                    </div>
                                </td>
                                {/if}

                            </tr>
                            {/foreach}

                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$list->render()|raw}
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
<script>
    function chakans(id) {
        var text = $('#looktext' + id).val();
        let width = 'auto';
        let height = 'auto';
        let content = '<pre style="padding:30px 30px;max-height:600px;overflow-y:scroll">' + text + '</pre>';
        layer.open({
            type: 1,
            maxmin: true, //打开放大缩小按钮
            title: '说明',
            area: [width, height],
            content: content,
        });
    }
</script>
{include file="public/footer"}
<script>
    layui.use(['upload', 'laydate'], function () {
        var $ = layui.jquery
        var laydate = layui.laydate;
        var upload = layui.upload;
        laydate.render({
            elem: '.timess'
            , type: 'date'
        });
        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            , accept: 'file'
            , url: '/shop/import_batch_send' //上传接口
            , before: function (obj) { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                layer.load(); //上传loading
            }, done: function (res) {
                layer.closeAll('loading'); //关闭loading
                //如果上传失败
                if (res.status == 0) {
                    str = '导入完成，失败个数' + res.data.length + '<br/>';
                    $.each(res.data, function (i, obj) {
                        str += '<div>第' + obj.key + '行:' + obj.msg + '</div>';
                    });
                    layer.open({
                        type: 0,
                        content: str,
                        yes: function () {
                            location.reload();
                        }
                    });
                    return false;
                } else {
                    layer.msg(res.msg, { icon: 2, time: 1000 });
                    return false;
                }
            }
            , error: function () {
                layer.closeAll('loading'); //关闭loading
                layer.msg('请求失败请重试', { icon: 2, time: 1000 });
                return false;

            }
        });
    });
</script>
<script>
    function open_alerterr(title, url, id, status, groups) {
        var html = '';
        var json = {:json_encode($types) };
        var check = '<select  class= "layui-input"  lay-search="" name="groups" lay-verify="required"><option value="">请选择项目分组</option>';
        $.each(json, function (key, item) {
            if (key == groups) {
                check += '<option selected  value="' + key + '">' + item + '</option>';
            } else {
                check += '<option  value="' + key + '">' + item + '</option>';
            }
        });
        check += '</select>';
        console.log(check);
        html = '<div class="layui-card-body layui-row layui-col-space10"><div class="layui-col-md12">' + check + '</div><div class="layui-col-md12"><input type="text" name="value1" class= "layui-input"  placeholder = "请填写报销说明，如无请填写无" lay-verify="required"></div ></div>';
        layer.open({
            type: 0,
            title: title,
            btn: ["确认", "关闭"],
            content: html,
            yes: function (value, index, elem) {
                var value1 = $("input[name='value1']").val();
                var value2 = $("select[name='groups']").val();
                if (!value1) {
                    layer.msg("请填写报销说明", { icon: 2, time: 1000 });
                    return false;
                }
                if (!value2) {
                    layer.msg("请选择分组", { icon: 2, time: 1000 });
                    return false;
                }
                $.post(
                    url,
                    { id: id, value: value1, groups: value2, status: 2 },
                    function (data) {
                        if (data.status == 0) {
                            layer.msg(data.msg, { icon: 6, time: 1000 }, function () {
                                // 获得frame索引
                                location.reload();
                                layer.close(index);
                            });
                        } else {
                            layer.msg(data.msg, { icon: 2, time: 1000 });
                        }
                    },
                    "json"
                );
            },
        });
    }
    //视频预览，传url,width,height
    function previewVideo(url, width, height) {
        console.log(url);
        width = width ? width : '65%';
        height = height ? height : '65%';
        let content = '<video width="100%" height="90%"  controls="controls" autobuffer="autobuffer"  autoplay="autoplay" loop="loop">' +
            '<source src="' + url + '" type="video/mp4"></source></video>';
        layer.open({
            type: 1,
            maxmin: true, //打开放大缩小按钮
            title: '视频播放',
            area: [width, height],
            content: content,
        });
    }
    function money_edit(title, url, id) {
        layer.prompt({
            formType: 0,
            value: 0,
            title: title,
        }, function (value, index, elem) {
            $.ajax({
                type: 'post',
                url: url,
                data: { id: id, money: value },
                success: function (res) {
                    if (res.code == 0) {
                        layer.msg(res.msg, { icon: 6, time: 1000 }, function () {
                            layer.close(index);
                            // 获得frame索引
                            location.reload();
                        });
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 1000 });
                    }
                }
            });
            return false;

        });
    }
    layui.use(['form', 'upload'], function () {
        var $ = layui.jquery
            , form = layui.form
            , layer = layui.layer;
    });
</script>
<script>
    layer.photos({
        photos: '#layer-photos'
        , anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
    });
</script>